package com.costaccounting.base.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.costaccounting.common.annotation.Log;
import com.costaccounting.common.core.controller.BaseController;
import com.costaccounting.common.core.domain.AjaxResult;
import com.costaccounting.common.enums.BusinessType;
import com.costaccounting.base.domain.ZsItemCategoryConfig;
import com.costaccounting.base.service.IZsItemCategoryConfigService;
import com.costaccounting.common.utils.poi.ExcelUtil;
import com.costaccounting.common.core.page.TableDataInfo;

/**
 * 项目分类面积Controller
 * 
 * @author ruoyi
 * @date 2021-11-18
 */
@RestController
@RequestMapping("/base/itemCategoryConfig")
public class ZsItemCategoryConfigController extends BaseController
{
    @Autowired
    private IZsItemCategoryConfigService zsItemCategoryConfigService;

    /**
     * 查询项目分类面积列表
     */
    @PreAuthorize("@ss.hasPermi('base:itemCategoryConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZsItemCategoryConfig zsItemCategoryConfig)
    {
        startPage();
        List<ZsItemCategoryConfig> list = zsItemCategoryConfigService.selectZsItemCategoryConfigList(zsItemCategoryConfig);
        return getDataTable(list);
    }

    /**
     * 导出项目分类面积列表
     */
    @PreAuthorize("@ss.hasPermi('base:itemCategoryConfig:export')")
    @Log(title = "项目分类面积", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ZsItemCategoryConfig zsItemCategoryConfig)
    {
        List<ZsItemCategoryConfig> list = zsItemCategoryConfigService.selectZsItemCategoryConfigList(zsItemCategoryConfig);
        ExcelUtil<ZsItemCategoryConfig> util = new ExcelUtil<ZsItemCategoryConfig>(ZsItemCategoryConfig.class);
        return util.exportExcel(list, "项目分类面积数据");
    }

    /**
     * 获取项目分类面积详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:itemCategoryConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(zsItemCategoryConfigService.selectZsItemCategoryConfigById(id));
    }

    /**
     * 新增项目分类面积
     */
    @PreAuthorize("@ss.hasPermi('base:itemCategoryConfig:add')")
    @Log(title = "项目分类面积", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZsItemCategoryConfig zsItemCategoryConfig)
    {
        return toAjax(zsItemCategoryConfigService.insertZsItemCategoryConfig(zsItemCategoryConfig));
    }

    /**
     * 修改项目分类面积
     */
    @PreAuthorize("@ss.hasPermi('base:itemCategoryConfig:edit')")
    @Log(title = "项目分类面积", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZsItemCategoryConfig zsItemCategoryConfig)
    {
        return toAjax(zsItemCategoryConfigService.updateZsItemCategoryConfig(zsItemCategoryConfig));
    }

    /**
     * 删除项目分类面积
     */
    @PreAuthorize("@ss.hasPermi('base:itemCategoryConfig:remove')")
    @Log(title = "项目分类面积", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zsItemCategoryConfigService.deleteZsItemCategoryConfigByIds(ids));
    }
}
